﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SenetExperimentsRunner.Logic.Genetic_Algorithm
{
    //represents a concrete heuristic
    class Heuristic
    {
        //constants
        public const int SUB_HEURISTICS_NUM = 7;
        
        //members
        private float[] m_coefficient = new float[SUB_HEURISTICS_NUM];
 
        //functions
        public Heuristic(){}

        //public Heuristic(float a0, float a1, float a2, float a3, float a4, float a5,
        //                    float a6, float a7, float a8, float a9, float a10, float a11,
        //                    float a12, float a13)
        //{
        //    m_coefficient[0] = a0;
        //    m_coefficient[1] = a1;
        //    m_coefficient[2] = a2;
        //    m_coefficient[3] = a3;
        //    m_coefficient[4] = a4;
        //    m_coefficient[5] = a5;
        //    m_coefficient[6] = a6;
        //    m_coefficient[7] = a7;
        //    m_coefficient[8] = a8;
        //    m_coefficient[9] = a9;
        //    m_coefficient[10] = a10;
        //    m_coefficient[11] = a11;
        //    m_coefficient[12] = a12;
        //    m_coefficient[13] = a13;

        //}

        //coefficient = מקדם
        public void setCoefficient(int index, float value)
        {
            m_coefficient[index] = value;
        }

        //coefficient = מקדם
        public float getCoefficient(int index)
        {
            return m_coefficient[index];
        }

        public void setCoefficients(int[] coefficients)
        {
            if (coefficients.Length != SUB_HEURISTICS_NUM)
            {
                throw new Exception("Heuristic.setCoefficients() : wrong number of coefficients");
            }

            for (int i = 0; i < SUB_HEURISTICS_NUM; ++i)
            {
                m_coefficient[i] = coefficients[i];
            }
        }

        public float[] Coefficients
        {
            get
            {
                return m_coefficient;
            }
        }

        public override string  ToString()
        {
            StringBuilder str = new StringBuilder();
            for (int i = 0; i < SUB_HEURISTICS_NUM; ++i)
            {
                str.Append("\t" + m_coefficient[i].ToString());
            }
            return str.ToString();
        }
    }
}
